
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>包管理工具 go mod · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="http.html" />
    
    
    <link rel="prev" href="goinstall.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    Part2 模拟商城
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="payflow.html">
            
                <a href="payflow.html">
            
                    
                    订单支付流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="goinstall.html">
            
                <a href="goinstall.html">
            
                    
                    go 语言环境安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.3" data-path="gomod.html">
            
                <a href="gomod.html">
            
                    
                    包管理工具 go mod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="http.html">
            
                <a href="http.html">
            
                    
                    实现http服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="http静态资源服务器.html">
            
                <a href="http静态资源服务器.html">
            
                    
                    http静态资源服务器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="mysql表设计.html">
            
                <a href="mysql表设计.html">
            
                    
                    mysql表设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="go的mysql操作.html">
            
                <a href="go的mysql操作.html">
            
                    
                    go的mysql操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="go的api接口实现.html">
            
                <a href="go的api接口实现.html">
            
                    
                    go的api接口实现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../alipay/">
            
                <a href="../alipay/">
            
                    
                    Part3 接入支付宝
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../alipay/flow.html">
            
                <a href="../alipay/flow.html">
            
                    
                    支付宝文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../alipay/secret.html">
            
                <a href="../alipay/secret.html">
            
                    
                    密码学-非对称加密
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">扩展</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../plugins.md">
            
                <span>
            
                    
                    插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../themes.md">
            
                <span>
            
                    
                    主题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../bookjson.md">
            
                <span>
            
                    
                    bookjson
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >包管理工具 go mod</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x5305;&#x7BA1;&#x7406;&#x5DE5;&#x5177;-gomod">&#x5305;&#x7BA1;&#x7406;&#x5DE5;&#x5177; gomod</h2>
<p>go&#x7684;&#x7A0B;&#x5E8F;&#x4F1A;&#x5206;&#x95E8;&#x522B;&#x7C7B;&#x7684;&#x7EC4;&#x7EC7;&#x6210;&#x82E5;&#x5E72;&#x7EC4;&#x6587;&#x4EF6;&#xFF0C;&#x6BCF;&#x7EC4;&#x6587;&#x4EF6;&#x88AB;&#x79F0;&#x4E3A;&#x4E00;&#x4E2A;&#x5305;&#x3002;<br></p>
<p>&#x6BCF;&#x4E2A;go&#x6587;&#x4EF6;&#x90FD;&#x5C5E;&#x4E8E;&#x4E14;&#x53EA;&#x80FD;&#x5C5E;&#x4E8E;&#x4E00;&#x4E2A;&#x5305;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x6E90;&#x6587;&#x4EF6;&#x7684;&#x7B2C;&#x4E00;&#x884C;&#x5FC5;&#x987B;&#x8981;&#x4F7F;&#x7528; <strong>package &#x5305;&#x540D;</strong>  &#x6765;&#x6307;&#x540D;&#x6587;&#x4EF6;&#x7684;&#x5305;&#x6240;&#x5C5E;&#x5173;&#x7CFB;&#x3002;<br></p>
<p>go&#x7684;&#x4EE3;&#x7801;&#x7EC4;&#x7EC7;&#x5C31;&#x662F;&#x901A;&#x8FC7;&#x5B9A;&#x4E49;&#x8FD9;&#x4E9B;&#x4E0D;&#x540C;&#x7684;&#x5305;&#x6765;&#x5B9E;&#x73B0;&#x7684;&#x3002;<br></p>
<p>go&#x7684;&#x6807;&#x51C6;&#x5E93;&#x4EE3;&#x7801;&#x5728;GOROOT/src&#x4E0B;&#xFF0C;&#x800C;&#x7528;&#x6237;&#x7684;&#x4EE3;&#x7801;&#x90FD;&#x5728;GOPATH/src&#x4E0B;&#xFF1B;<br>
&#x5F00;&#x53D1;&#x65F6;&#x6240;&#x6709;&#x7684;&#x5305;&#x90FD;&#x653E;&#x5728;GOPATH/src&#x4E0B; &#x5F88;&#x6DF7;&#x4E71;&#xFF0C;&#x6240;&#x4EE5;go &#x5728;go1.11&#x4E4B;&#x540E;&#x7684;&#x7248;&#x672C;&#x589E;&#x52A0;&#x4E86;go module&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x7B80;&#x79F0; <strong>gomod</strong>&#x3002;</p>
<h4 id="&#x4EC0;&#x4E48;&#x662F;module&#xFF1F;">&#x4EC0;&#x4E48;&#x662F;module&#xFF1F;</h4>
<p>&#x5728;go&#x8BED;&#x8A00;&#x5B89;&#x88C5;&#x7684;&#x7AE0;&#x8282;&#x4E2D;&#xFF0C;&#x4ECB;&#x7ECD;&#x4E86;&#x6240;&#x6709;&#x7684;go&#x6E90;&#x4EE3;&#x7801;&#x90FD;&#x9700;&#x8981;&#x653E;&#x7F6E;&#x5728;GOPATH&#x4E2D;&#xFF1B;&#x4F46;&#x662F;&#x5982;&#x679C;&#x4E0D;&#x540C;&#x7684;&#x5DE5;&#x7A0B;&#x4F9D;&#x8D56;&#x4E86;&#x4E0D;&#x540C;&#x7248;&#x672C;&#x7684;&#x76F8;&#x540C;go&#x6E90;&#x7801;&#x6A21;&#x5757;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5C31;&#x4F1A;&#x51FA;&#x73B0;&#x51B2;&#x7A81;&#x3002;&#x90A3;&#x4E48;&#x4E3A;&#x4E86;&#x8131;&#x79BB;GOPATH&#x7684;&#x4EE3;&#x7801;&#x7BA1;&#x7406;&#xFF0C;module&#x5E94;&#x8FD0;&#x800C;&#x751F;&#x3002;<br></p>
<p>module &#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x6211;&#x4EEC;&#x7BA1;&#x7406;&#x9879;&#x76EE;&#x4EE3;&#x7801;&#x4F7F;&#x7528;&#x7684;&#xFF0C;&#x5B83;&#x662F;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#x63A7;&#x5236;&#x5355;&#x5143;&#xFF0C;&#x662F;&#x4E00;&#x7CFB;&#x5217;&#x76F8;&#x5173;&#x5305;&#x7684;&#x96C6;&#x5408;&#x8868;&#x793A;&#x3002;<br></p>
<h4 id="&#x5F00;&#x542F;gomod&#x53EF;&#x7528;">&#x5F00;&#x542F;gomod&#x53EF;&#x7528;</h4>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x73AF;&#x5883;&#x53D8;&#x91CF;GO111MODULE&#x9009;&#x62E9;&#x5F00;&#x542F;&#x6216;&#x8005;&#x662F;&#x5173;&#x95ED;module&#x6A21;&#x5757;&#x7684;&#x652F;&#x6301;&#x3002;&#x6709;&#x4E09;&#x4E2A;&#x503C;&#x53EF;&#x9009;:</p>
<ul>
<li>GO111MODULE=off, &#x5173;&#x95ED;module&#x529F;&#x80FD;, &#x5230;GOPATH&#x4E2D;&#x5BFB;&#x627E;&#x4F9D;&#x8D56;</li>
<li>GO111MODULE=on, &#x4EE3;&#x7801;&#x4E0D;&#x4F1A;&#x5230;GOPATH&#x4E2D;&#x53BB;&#x5BFB;&#x627E;</li>
<li>GO111MODULE=auto, go&#x547D;&#x4EE4;&#x884C;&#x6839;&#x636E;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x6765;&#x51B3;&#x5B9A;&#x662F;&#x5426;&#x542F;&#x7528;module, &#x5F53;&#x5728;GOPATH&#x76EE;&#x5F55;&#x5916;&#x4E14;&#x6709;go.mod&#x6587;&#x4EF6;&#x65F6;&#x542F;&#x7528;module</li>
</ul>
<h4 id="&#x521B;&#x5EFA;&#x65B0;&#x9879;&#x76EE;">&#x521B;&#x5EFA;&#x65B0;&#x9879;&#x76EE;</h4>
<p>&#x521B;&#x5EFA;&#x9879;&#x76EE;&#x6587;&#x4EF6;&#x5939;</p>
<pre><code>mkdir payment
cd payment
</code></pre><p>&#x521D;&#x59CB;&#x5316;module</p>
<pre><code>go mod init github.com/willierGo/payment
</code></pre><p><strong>go mod init</strong>&#x540E;&#x9762;&#x662F;&#x6A21;&#x5757;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x6267;&#x884C;&#x5B8C;&#x8BE5;&#x547D;&#x4EE4;&#x5C31;&#x4F1A;&#x751F;&#x6210; <strong>go.mod</strong> &#x6587;&#x4EF6;, go.mod&#x6587;&#x4EF6;&#x5C31;&#x6807;&#x8BC6;&#x7740;&#x5B83;&#x6240;&#x5728;&#x7684;&#x76EE;&#x5F55;&#x662F;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x3002;</p>
<h4 id="gomod&#x7684;&#x5176;&#x4ED6;&#x5E38;&#x7528;&#x547D;&#x4EE4;">gomod&#x7684;&#x5176;&#x4ED6;&#x5E38;&#x7528;&#x547D;&#x4EE4;</h4>
<table>
<thead>
<tr>
<th>&#x547D;&#x4EE4;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>go mod tidy</td>
<td>&#x62C9;&#x53D6;&#x7F3A;&#x5C11;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x79FB;&#x9664;&#x4E0D;&#x7528;&#x7684;&#x6A21;&#x5757;</td>
</tr>
<tr>
<td>go mod verify</td>
<td>&#x9A8C;&#x8BC1;&#x4F9D;&#x8D56;&#x662F;&#x5426;&#x6B63;&#x786E;</td>
</tr>
<tr>
<td>go mod graph</td>
<td>&#x6253;&#x5370;&#x6A21;&#x5757;&#x4F9D;&#x8D56;&#x56FE;</td>
</tr>
<tr>
<td>go mod download</td>
<td>&#x4E0B;&#x8F7D;&#x4F9D;&#x8D56;&#x5305;</td>
</tr>
<tr>
<td>go mod version</td>
<td>&#x5C06;&#x4F9D;&#x8D56;&#x590D;&#x5236;&#x5230;vendor&#x4E0B;</td>
</tr>
</tbody>
</table>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="goinstall.html" class="navigation navigation-prev " aria-label="Previous page: go 语言环境安装">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="http.html" class="navigation navigation-next " aria-label="Next page: 实现http服务">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"包管理工具 go mod","level":"1.2.3","depth":2,"next":{"title":"实现http服务","level":"1.2.4","depth":2,"path":"two_shop/http.md","ref":"two_shop/http.md","articles":[]},"previous":{"title":"go 语言环境安装","level":"1.2.2","depth":2,"path":"two_shop/goinstall.md","ref":"two_shop/goinstall.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"two_shop/gomod.md","mtime":"2020-05-26T00:02:49.875Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-05-30T14:47:16.991Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

